/**
 * 
 */
package com.gov.ec.rsv.convertidores;


import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;


/**
 *  Esta clase representa el convertidor para los menús
 *  cargados en el arbol en permisos
 *	@author martosfre
 *	May 12, 2011
 *  see www.matoosfe.com
 */
public class ConvertidorArbol implements Converter {
	

	/* (non-Javadoc)
	 * @see javax.faces.convert.Converter#getAsObject(javax.faces.context.FacesContext, javax.faces.component.UIComponent, java.lang.String)
	 */
	@Override
	public Object getAsObject(FacesContext fcx, UIComponent arg1, String value) {
		if (value == null || value.equals("")) {
			return "";
		} else {
			return value.toString().split("-")[0];
		}
	}

	/* (non-Javadoc)
	 * @see javax.faces.convert.Converter#getAsString(javax.faces.context.FacesContext, javax.faces.component.UIComponent, java.lang.Object)
	 */
	@Override
	public String getAsString(FacesContext fcx, UIComponent componente, Object value) {
		if (value == null || value.equals("")) {
			return "";
		} else {
			return value.toString().split("-")[1];
		}
	}


}
